﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BOL;
using BOL.Ventas;
using UtilityExtensions;
using System.Web.UI.DataVisualization.Charting;
using System.Data.SqlClient;
using Website.Logger;
using System.Web.UI.HtmlControls;
using System.Drawing;

namespace UILGestion.VentaAdmin.Chart
{
    public partial class Chart03 : System.Web.UI.UserControl
    {
        
            protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                

                if (!this.IsPostBack)
                {

                    idProyecto.Value = (string)Request.QueryString["idProyecto"];
                    FormatForm();
                }
            }
            catch (SqlException sqlex)
            {
                WebServerSideSqlError.Log(sqlex);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                 "uniqueKey" + DateTime.Now, "alert('" + sqlex.Message.Replace("'", "") + "');", true);


            }
            catch (Exception ex)
            {
                WebServerSideError.Log(ex);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                 "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

            }
        }


                         
        private void FormatForm()
        {

              //Chart1.Series["Series1"].ChartType = SeriesChartType.Line;
             // Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
              
            // BindDataItem();
        }
        public void LoadChart(int idProyecto,int Periodo,bool esCantidad)
        {


            var proyeccion = new OrdenVentaBL().GetVentaBruta(idProyecto,esCantidad,
                                                Periodo, 1);

            var i = -1;
            foreach (var item in proyeccion)
            {
                i++;
            
                Chart1.Series[0].Points[i].YValues[0] = Convert.ToDouble(item.valorBruto);
                Chart1.Series[1].Points[i].YValues[0] = Convert.ToDouble(item.valorVenta);
                
            }

            Chart1.Titles[0].Text = " Año:{0}".Fmt(Periodo);

            
        }

       
    }
}